package seven_ThreadPool;

import java.util.concurrent.*;

public class HandlerSocketServerPool {
    // 创建一个线程池的成员变量
    private ExecutorService es;

    /*
    public ThreadPoolExecutor(int corePoolSize,
                              int maximumPoolSize,
                              long keepAliveTime,
                              TimeUnit unit,
                              BlockingQueue<Runnable> workQueue,
                              ThreadFactory threadFactory,
                              RejectedExecutionHandler handler) {
     */
    // 创建这个类的对象的时候就需要初始化线程池对象
    public HandlerSocketServerPool(int corePoolSize, int maximumPoolSize, int queueSize) {
        es = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, 120L, TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(queueSize), Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
    }
    // 提供一个方法来提交任务给线程池的任务队列来暂存，等着线程池来处理

    public void execute(Runnable target) {
        es.execute(target);
    }


}
